package main


type NumArray struct {
	sums []int
}


func Constructor(nums []int) NumArray {
	// 计算sums
	sums := make([]int, len(nums)+1)
	for i, v := range nums {
		sums[i+1] = sums[i]+v
	}
	return NumArray{sums}
}

// [left,right)之间的和
// 前缀和   sum(right)-sum(left)
func (this *NumArray) SumRange(left int, right int) int {
	return this.sums[right+1] - this.sums[left]
}


/**
 * Your NumArray object will be instantiated and called as such:
 * obj := Constructor(nums);
 * param_1 := obj.SumRange(left,right);
 */